from create_import import *
from table_list import *


def create_service(table: str):
    """
    创建service
    """
    _current = "service"
    param = Params(table)
    _class_name = (
        "I" + param.class_name_basic + _current[0].upper() + _current[1::]
    )  # 当前类名

    _package_name = f"package {param.package_name_basic}.{_current};"  # 当前包名

    _java_output_path = f"{param.output_java_path_basic}/{_current}"  # java文件路径

    # print(f">>输出路径{_java_output_path}")
    if not os.path.exists(_java_output_path):
        os.makedirs(_java_output_path)

    _java_output_file = f"{_java_output_path}/{_class_name}.java"

    _print_output = output(_java_output_file)  # print 的output

    def printf(val):
        print(val, file=_print_output)

    demoblock = f"""{_package_name}

import com.baomidou.mybatisplus.extension.service.IService;

import {param.package_name_basic}.entity.{param.class_name_basic};


public interface {_class_name} extends IService<{param.class_name_basic}> {'{'}

    """
    printf(demoblock)  # import block

    printf("}")
    print(f"{param.table}创建{_current} - 完成")


if __name__ == "__main__":
    for table in table_list:
        create_service(table)
        # break
